home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Utilitare / emu / Emu8086_Setup_307c.exe / {app} / Samples / bcd_aaa.asm < prev    next >
Assembly Source File  |  2002-11-28  |  713b  |  52 lines

  1. ; This example shows the use
  2. ; of AAA instruction (ASCII
  3. ; Adjust after Addition).
  4. ; It is used to add huge
  5. ; BCD numbers.
  6.  
  7. #make_COM#
  8.  
  9. ORG     100h
  10.  
  11. ; first number '9':
  12. MOV     AH, 09h
  13.  
  14. ; second number '5':
  15. MOV     AL, 05h
  16.  
  17. ; AL = AL + AH =
  18. ;    = 09h + 05h = 0Eh
  19. ADD     AL, AH
  20.  
  21. ; clear tens byte of BCD
  22. ; result:
  23. XOR     AH, AH
  24.  
  25. ; adjust result to BCD form,
  26. ; AH = 1, AL = 4  ->  '14'
  27. AAA
  28.  
  29. ; print the result:
  30.  
  31. ; store contents of
  32. ; AX register:
  33. MOV     DX, AX
  34.  
  35. ; print first digit:
  36. MOV     AH, 0Eh
  37. ; convert to ascii:
  38. OR      DH, 30h
  39. MOV     AL, DH
  40. INT     10h
  41.  
  42. ; print second digit:
  43. ; convert to ascii:
  44. OR      DL, 30h
  45. MOV     AL, DL
  46. INT     10h
  47.  
  48.  
  49. RET
  50.  
  51. END
  52.